<?php
	namespace app\admin\controller;
	use think\Controller;
	use think\Session;

	//后台权限
	class Allow extends Controller
	{

		//初始化方法
	    public function _initialize(){

	    	
	    	//检测用户是否登录
	    	if(!Session::get('aname')){
	    		$this->error("请先登录","/login/login");
	    		exit;
	    	    }
	    	    $request=request();
	    		//获取控制qi
	    		$controller=strtolower($request->controller());
	    		//获取方法
	    		$action=$request->action();
	    		//获取权限列表
	    		$nodelist=Session::get('nodelist');
	    		//对bi 
	    		if(empty($nodelist[$controller]) || !in_array($action,$nodelist[$controller])){
	    			$this->error('您没有权限','/admin/index');
	    			exit;
	    		}
	    	
		}
	}
?>
